package com.pacy.pacybaseproject.viewmodels;

import android.app.Application;
import android.view.View;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.pacy.pacybaseproject.activitys.AcDetailActivity;
import com.pacy.pacybaseproject.activitys.AllReceiveActivity;
import com.pacy.pacybaseproject.adapters.ExchangeHistoryAdapter;
import com.pacy.pacybaseproject.adapters.ReceiveAdapter;
import com.pacy.pacybaseproject.utils.Constants;

import io.reactivex.annotations.NonNull;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

/**
 * @author PACY
 * @date 2023/12/20
 * description: 兑换记录
 */
public class ExchangeHistoryViewModel extends BaseViewModel {
    public ExchangeHistoryAdapter exchangeHistoryAdapter;
    public ExchangeHistoryViewModel(@NonNull Application application) {
        super(application);
    }

    @Override
    protected void init() {
        super.init();
        initAdapter();
    }

    public void initAdapter(){

        exchangeHistoryAdapter =new ExchangeHistoryAdapter();
        exchangeHistoryAdapter.setNewInstance(Constants.getTestData(5));
        exchangeHistoryAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                startActivity(AcDetailActivity.class);
            }
        });

    }

    public BindingCommand toAllPage=new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            startActivity(AllReceiveActivity.class);
        }
    });
}
